package com.zrt.pad.socketcon;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

public class SocketClient extends Thread{
	private Context context;
	private final String ip;
	private final int port;
	private String order_content;
	private Handler handler;
	
	public SocketClient(Context context,String ip, int port,String str,Handler handler) {
		this.handler=handler;
		this.context = context;
		this.ip = ip;
		this.port = port;
		this.order_content=str;
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
			
			Socket socket  = new Socket(ip,port);
			//int count = 0;
			OutputStream os = socket .getOutputStream();
			PrintWriter pw = new PrintWriter(os);
			
			pw.write(new String(this.order_content));
			pw.flush();
			pw.close();
			os.close();
			socket.close();	
		
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	

}
